package com.gears_software.sxdc.dccx.data.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;


import com.gears_software.sxdc.dccx.data.model.FeeModel;
import com.gears_software.sxdc.dccx.ui.view.ChargeScheduleListItemView;
import com.gears_software.sxdc.dccx.ui.view.ChargeScheduleListItemView_;

import java.util.List;

/**
 * Created by SunMuran on 2017/9/20.
 * 收费明细listView的adapter
 */

public class ChargeScheduleAdapter extends BaseAdapter {
    Context context;
    List<FeeModel> list;

    public ChargeScheduleAdapter(Context context, List<FeeModel> list) {
        this.context = context;
        this.list = list;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public FeeModel getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ChargeScheduleListItemView itemView;
        if (convertView == null) {
            itemView = ChargeScheduleListItemView_.build(context);
        } else {
            itemView = (ChargeScheduleListItemView) convertView;
        }
        itemView.bind(list.get(position));
        return itemView;
    }
}
